package first.servlet;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;

import first.command.AddNewLiterature;
import first.command.Command;


public class RequestBuilder {
	private static  RequestBuilder instance = null;
	
	private  HashMap <String,Command> commands = new HashMap<String,Command>();
	
	private RequestBuilder(){
		commands.put("addNewLiterature", new AddNewLiterature());		
	}
	
	public  static RequestBuilder getInstance(){
		if (instance == null){
			instance = new RequestBuilder();
		}
		return instance;
	}
	
	public Command getCommand(HttpServletRequest request){
		
		String action = request.getParameter("command");
		
		Command command = commands.get(action);
	
//		if (command == null){
//			command = new NoCommand();
//		}
		return command;
		
	}
}
